﻿using System;
using System.Reactive.Disposables;
using System.Reactive.Linq;

namespace Event.ReactiveProgrammingConsole
{
    public static class ObservableFactory
    {

        public static IObservable<T> Empty<T>()
        {
            return Observable.Create<T>(o =>
            {
                o.OnCompleted();
                return Disposable.Empty;
            });
        }

        public static IObservable<T> Return<T>(T value)
        {
            return Observable.Create<T>(o =>
            {
                o.OnNext(value);
                o.OnCompleted();
                return Disposable.Empty;
            });
        }

        public static IObservable<T> Never<T>()
        {
            return Observable.Create<T>(o => Disposable.Empty);
        }

        public static IObservable<T> Throws<T>(Exception exception)
        {
            return Observable.Create<T>(o =>
            {
                o.OnError(exception);
                return Disposable.Empty;
            });
        }
 

    }
}